// voter-client.c -- Client program for voter-server.
//=========================================================================
// Copyright (C) 2024 The C++ Component Model(COMO) Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//=========================================================================

#ifndef __VOTER_CLIENT_H__
#define __VOTER_CLIENT_H__

/**
 * Low level terminal handling.
 */

#define IB_MAX 128
struct InputBuffer {
    char buf[IB_MAX];       // Buffer holding the data.
    int len;                // Current length.
};

/**
 * inputBuffer*() return values:
 */
#define IB_ERR 0        // Sorry, unable to comply.
#define IB_OK 1         // Ok, got the new char, did the operation, ...
#define IB_GOTLINE 2    // Hey, now there is a well formed line to read.

void DisableRawModeAtExit(void);
int SetRawMode(int fd, int enable);
void TerminalCleanCurrentLine(void);
void TerminalCursorAtLineStart(void);
void InputBufferHide(struct InputBuffer *ib);
void InputBufferShow(struct InputBuffer *ib);
int InputBufferAppend(struct InputBuffer *ib, int c);
void InputBufferClear(struct InputBuffer *ib);
int InputBufferFeedChar(struct InputBuffer *ib, int c);

#endif // __VOTER_CLIENT_H__
